<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
<title>跟随鼠标移动的图片</title>

</head>

<body onload="makesnake()" background="mr.jpg">
<div id="tdiv" style='position:absolute'>
	<img src='Mymouse.gif' width='32' height='32'>
</div>
<script type="text/javascript">
var x,y;
function handlerMM(){
	x =  window.event.x + document.body.clientLeft;
	y =	 window.event.y + document.body.clientTop;
}
function makesnake() {
    	var ob = document.getElementById("tdiv");
    	ob.style.left=x+"px";
		ob.style.top=y+"px";
		var timer=setTimeout("makesnake()",10);
}
document.onmousemove = handlerMM;
</script>

</body>
</html>
